---
title: "Background Image"
description: "Utilities for controlling an element's background image."
---

import plugin from 'tailwindcss/lib/plugins/backgroundImage'
import { Heading } from '@/components/Heading'
import { Variants } from '@/components/Variants'
import { Disabling } from '@/components/Disabling'

export const classes = { plugin }

## Linear gradients

To give an element a linear gradient background, use one of the `bg-gradient-{direction}` utilities, in combination with the [gradient color stop](/docs/gradient-color-stops) utilities.

```html
<template preview>
  <div class="h-24 bg-gradient-to-r from-orange-400 via-red-500 to-pink-500"></div>
</template>

<div class="**bg-gradient-to-r from-yellow-400 via-red-500 to-pink-500** ..."></div>
```

## Responsive

To control the background image of an element at a specific breakpoint, add a `{screen}:` prefix to any existing background image utility. For example, use `md:bg-gradient-to-r` to apply the `bg-gradient-to-r` utility at only medium screen sizes and above.

```html
<div class="bg-gradient-to-l **md:bg-gradient-to-r** ..."></div>
```

For more information about Tailwind's responsive design features, check out the [Responsive Design](/docs/responsive-design) documentation.

## Customizing

### Background Images

By default, Tailwind includes background image utilities for creating linear gradient backgrounds in eight directions.

You can add your own background images by editing the `theme.backgroundImage` section of your `tailwind.config.js` file:

```diff-js
  // tailwind.config.js
  module.exports = {
    theme: {
      extend: {
        backgroundImage: {
+         'hero-pattern': "url('/img/hero-pattern.svg')",
+         'footer-texture': "url('/img/footer-texture.png')",
        }
      }
    }
  }
```

These don't just have to be gradients — they can be any background images you need.

These classes will take the form `bg-{key}`, so `hero-pattern` will become `bg-hero-pattern` for example.

### Variants

<Variants plugin="backgroundImage" />

### Disabling

<Disabling plugin="backgroundImage" />
